﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data.SqlClient;
using SalePartial.Utility;
using SalePartial.Model;
using System.Data;
using SalePartial.IDAL;

namespace SalePartial.SQLServerDAL
{

    //<DataObject(True)> _
    public class XPRating : IXPRating
    {
        // Methods
        //<DataObjectMethod(DataObjectMethodType.Delete)> _
        public  int Delete(Guid RatingID)
        {
            int RowsAffected = 0;
            DbObject dbo = new DbObject(GlobalSetting.ConnectionString);
            SqlParameter[] parameters = new SqlParameter[] { new SqlParameter("RatingID", RatingID) };
            return dbo.RunProcedure("[dbo].[xunpan_XPRatingDelete]", parameters, RowsAffected);
        }

        //<DataObjectMethod(DataObjectMethodType.Delete)> _
        public  int DeleteDynamic(string v_whereCondition)
        {
            int RowsAffected = 0;
            DbObject dbo = new DbObject(GlobalSetting.ConnectionString);
            SqlParameter[] parameters = new SqlParameter[] { new SqlParameter("WhereCondition", v_whereCondition) };
            return dbo.RunProcedure("[dbo].[xunpan_XPRatingsDeleteDynamic]", parameters, RowsAffected);
        }

        //<DataObjectMethod(DataObjectMethodType.Insert)> _
        public  int Insert(XPRatingInfo info)
        {
            int RowsAffected = 0;
            DbObject dbo = new DbObject(GlobalSetting.ConnectionString);
            SqlParameter[] parameters = new SqlParameter[] {
			new SqlParameter("RatingID", info.RatingID),
			new SqlParameter("RatingTargetID", info.RatingTargetID),
			new SqlParameter("RatingOwnerID", info.RatingOwnerID),
			new SqlParameter("RatingUserID", info.RatingUserID),
			new SqlParameter("RatingSubject", info.RatingSubject),
			new SqlParameter("RatingValue", info.RatingValue),
			new SqlParameter("RatingDate", info.RatingDate),
			new SqlParameter("RatingComment", info.RatingComment)
		};
            return dbo.RunProcedure("[dbo].[xunpan_XPRatingInsert]", parameters, RowsAffected);
        }

        //<DataObjectMethod(DataObjectMethodType.Select)> _
        public  DataSet SelectAll()
        {
            DbObject dbo = new DbObject(GlobalSetting.ConnectionString);
            SqlParameter[] parameters = new SqlParameter[0];
            return dbo.RunProcedure("[dbo].[xunpan_XPRatingsSelectAll]", parameters, "XPRating_All");
        }

        //<DataObjectMethod(DataObjectMethodType.Fill)> _
        public  DataSet SelectDynamic(string v_whereCondition, string v_orderByExpression)
        {
            DbObject dbo = new DbObject(GlobalSetting.ConnectionString);
            SqlParameter[] parameters = new SqlParameter[] {
			new SqlParameter("WhereCondition", v_whereCondition),
			new SqlParameter("OrderByExpression", v_orderByExpression)
		};
            return dbo.RunProcedure("[dbo].[xunpan_XPRatingsSelectDynamic]", parameters, "XPRating_Dynamic");
        }

        //<DataObjectMethod(DataObjectMethodType.Fill)> _
        public  DataSet SelectPaged()
        {
            DbObject dbo = new DbObject(GlobalSetting.ConnectionString);
            SqlParameter[] parameters = new SqlParameter[0];
            return dbo.RunProcedure("[dbo].[xunpan_XPRatingsSelectPaged]", parameters, "XPRating_Paged");
        }

        //<DataObjectMethod(DataObjectMethodType.Select)> _
        public  SqlDataReader SelectReader(Guid RatingID)
        {
            DbObject dbo = new DbObject(GlobalSetting.ConnectionString);
            SqlParameter[] parameters = new SqlParameter[] { new SqlParameter("RatingID", RatingID) };
            return dbo.RunProcedure("[dbo].[xunpan_XPRatingSelect]", parameters);
        }

        //<DataObjectMethod(DataObjectMethodType.Select)> _
        public  DataSet SelectSingle(Guid RatingID)
        {
            DbObject dbo = new DbObject(GlobalSetting.ConnectionString);
            SqlParameter[] parameters = new SqlParameter[] { new SqlParameter("RatingID", RatingID) };
            DataSet ds = dbo.RunProcedure("[dbo].[xunpan_XPRatingSelect]", parameters, "XPRating_Single");
            DataTable dt = ds.Tables["XPRating_Single"];
            return ds;
        }

        //<DataObjectMethod(DataObjectMethodType.Update)> _
        public int Update(XPRatingInfo info)
        {
            int RowsAffected = 0;
            DbObject dbo = new DbObject(GlobalSetting.ConnectionString);
            SqlParameter[] parameters = new SqlParameter[] {
			new SqlParameter("RatingID", info.RatingID),
			new SqlParameter("RatingTargetID", info.RatingTargetID),
			new SqlParameter("RatingOwnerID", info.RatingOwnerID),
			new SqlParameter("RatingUserID", info.RatingUserID),
			new SqlParameter("RatingSubject", info.RatingSubject),
			new SqlParameter("RatingValue", info.RatingValue),
			new SqlParameter("RatingDate", info.RatingDate),
			new SqlParameter("RatingComment", info.RatingComment)
		};
            return dbo.RunProcedure("[dbo].[xunpan_XPRatingUpdate]", parameters, RowsAffected);
        }

    }


}
